
cmake_minimum_required(VERSION 3.5.1)

project(android-repo-analyzer LANGUAGES CXX VERSION 1.3.4.0)

include(cmake/SparkWithGit.cmake)
spark_initialize_modules()

include(cmake/AndroidRepoTool.cmake)

# 资源文件路径
set(QRC_SOURCES "src/assets/resource.qrc")

# 控制 qDebug 行为
if(CMAKE_BUILD_TYPE MATCHES "Release")
    add_compile_definitions(QT_NO_WARNING_OUTPUT=1 QT_NO_DEBUG_OUTPUT=1)
# else()
#     add_compile_definitions(DEBUG_REPO=${CMAKE_SOURCE_DIR})
endif(CMAKE_BUILD_TYPE MATCHES "Release")

spark_add_library_path(extra
    src/cache
    src/overlayfs/dialog
    src/manager
    src/solutions
    src/utils

    src/entry

    src/ui
    src/ui/dialog
    src/ui/widgets
    src/ui/widgets/others
)
target_link_qt5(extra)

spark_add_executable_path(${PROJECT_NAME}
    src
    ${QRC_SOURCES}
)
target_link_extra(${PROJECT_NAME})
spark_framework_include_with_git(extra
    https://gitee.com/spark-framework-libs/network-access-libs
    FEATURES httpmanager
)
spark_framework_include_with_git(extra
    https://gitee.com/spark-framework-libs/spark-framework-features
    FEATURES qd version screenutil dbusutil eaters baseutil
)
spark_framework_include_with_git(extra
    https://gitee.com/spark-framework-libs/threading-manager-libs
    FEATURES threading
)
spark_framework_include_with_git(extra
    https://gitee.com/zinface/infomation-tips
    FEATURES procutils
)
spark_framework_include_with_git(extra
    https://gitee.com/zinface/qt.examples
    FEATURES linux_open_in_terminal
)

# 示例集合
option(ENABLE_BUILD_EXAMPLES "Enable Build Examples." OFF)
if(ENABLE_BUILD_EXAMPLES)
    include(examples/dev.cmake)
endif(ENABLE_BUILD_EXAMPLES)

# 测试集合
option(ENABLE_BUILD_TESTS "Enable Build Tests." OFF)
if(ENABLE_BUILD_TESTS)
    add_subdirectory(tests)
endif(ENABLE_BUILD_TESTS)


# 内容默认应用名称: Name= 应与项目名称相同
spark_desktop_macros(
    # 应用名称: Name=
    "${PROJECT_NAME}" 
    # 应用名称: Name[zh_CN]=
    "Android 开源项目分析器" 
    # 应用说明: Comment=
    "一个可以帮助您了解 Android/Repo 开源项目信息的分析器" 
    # 应用类型: Type=
    "Application" 
    # 执行程序: Exec=
    "/usr/bin/${PROJECT_NAME} %f" 
    # 图标路径: Icon=
    "/usr/share/${PROJECT_NAME}/icon.png" 
    # 应用分类: Category=
    "Utility" 
    # MIME类型: MimeType=
    "inode/directory"
)
install(TARGETS ${PROJECT_NAME}
    DESTINATION /usr/bin)
install(FILES assets/icon.png
    DESTINATION /usr/share/${PROJECT_NAME})
install(FILES ${SPARK_DESKTOP_FILE}
    DESTINATION /usr/share/applications)

# 注释行(使用方式)
add_package_descript(cmake/spark-deb-package.descript)

# 1. 在顶层构建中导入 Appimage 的构建
add_appimage_icon(assets/spark.png)       # 添加到 Appimage 中的默认的图标
add_appimage_desktop()                    # 添加到 Appimage 中的默认desktop(使用来自 Spark 构建的 Desktop 构建中配置的信息(必须要求 spark-desktop))
add_appimage_target(${PROJECT_NAME})      # 添加到 Appimage 中的默认目标，应用对 Appimage 的构建
